<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'emp_list.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<script type="text/javascript" src="js/jquery-1.11.1.js"></script>
	<script type="text/javascript">
		function delete_emp(id){
			var r=window.confirm("确定要删除数据吗？");
			if(r){
				location.href="emp/deleteEmp.do?id="+id;
			}
		}
		
	</script>
  </head>
  
  <body>
  	<div align="center"> <input type="button" value="新增" onclick="location.href='emp/toAddEmp.do'"></div>
    <table width="60%" border="1" cellpadding="2" cellspacing="0">
    	<tr>
    		<th>EMPNO</th>
    		<th>ENAME</th>
    		<th>JOB</th>
    		<th>MGR</th>
    		<th>HIREDATE</th>
    		<th>SAL</th>
    		<th>COMM</th>
    		<th>DEPTNO</th>
    		<th></th>
    	</tr>
    	<c:forEach items="${emps}" var="emp">
    		<tr>
    			<td>${emp.empno}</td>
    			<td>${emp.ename}</td>
    			<td>${emp.job}</td>
    			<td>${emp.mgr}</td>
    			<td>${emp.hiredate}</td>
    			<td>${emp.sal}</td>
    			<td>${emp.comm}</td>
    			<td>${emp.deptno}</td>
    			<td>
    				<input type="button" value="修改" onclick="location.href='emp/toUpdateEmp.do?id=${emp.empno}'" />
    				<input type="button" value="删除" onclick="delete_emp(${emp.empno});"/>
    			</td>
    		</tr>
    		
    	</c:forEach>
    </table>
  </body>
</html>
